#!/usr/bin/env python
# coding=utf-8

filename = 'guest_book.txt'

with open(filename, 'a') as f_object:
    print("输入'q'退出循环！")
    while True:
        name = input("请输入你的名字：")
        if name == 'q':
            break
        f_object.write(name + '\n')
        print("你好{}".format(name))

